package com.csiec.clock.activity.daka;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

import com.csiec.clock.R;
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;

import org.w3c.dom.Text;

public class IdeaActivity extends AppCompatActivity {

    Button button;
    TextView t1, t2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_idea);
        //键盘弹起时，布局不会被顶上去
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);

        button = findViewById(R.id.idea_btn);
        t1 = findViewById(R.id.ed_content);
        t2 = findViewById(R.id.ed_tel);

        button.setOnClickListener(v -> {
            if ("".equals(t1.getText().toString())) {
                showTip(QMUITipDialog.Builder.ICON_TYPE_FAIL, "请填写您的建议！！！");
            } else {
                showTip(QMUITipDialog.Builder.ICON_TYPE_SUCCESS, "感谢您的建议！！！");
                t1.setText("");
                t2.setText("");
            }
        });
    }


    //提示悬浮窗
    public void showTip(int type, String msg) {
        QMUITipDialog tipDialog = new QMUITipDialog.Builder(this)
                .setIconType(type)
                .setTipWord(msg)
                .create();
        tipDialog.show();
        button.postDelayed(tipDialog::dismiss, 2000);
    }
}